<!-- 商品订单 -->
<template>
  <div>
    <van-nav-bar title="点餐" fixed placeholder>
      <template slot="left">
        <span @click="$router.back()">
          <van-icon name="arrow-left" /> 返回
        </span>
      </template>
    </van-nav-bar>
    <van-tabs sticky offset-top="46">
      <van-tab v-for="data in cate" :key="data.cateId" :title="data.cateName">
        <Goods :cate_id="data.cateId"></Goods>
      </van-tab>
    </van-tabs>
  </div>
</template>

<script>
import { Toast } from "vant";
import { getCateAll } from "../../api/shop";
import Goods from "./components/goods.vue";
export default {
  name: "Shop",
  data() {
    return {
      cate: "",
    };
  },
  methods: {
    async create_getCateAll() {
      try {
        const { data } = await getCateAll();
        console.log(data);
        if (data.status === 500) return Toast.fail(data.message);
        this.cate = data.data;
      } catch (error) {
        console.log(error);
        if (!window.localStorage.getItem('userInfo')) {
          Toast.fail("请先登录!");
          this.$router.replace("/my");
        }
      }
    },
  },
  created() {
    this.create_getCateAll();
  },
  components: {
    Goods,
  },
};
</script>


<style lang= "less" scoped>
.nav {
  height: 40px;
  line-height: 40px;
  text-align: center;
  background-color: skyblue;
  font-weight: 600;
  color: white;
}
</style>